AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")

function ENT:Initialize()
	self.Entity:SetModel("models/katharsmodels/syringe_out/syringe_out.mdl")
	self.Entity:PhysicsInit(SOLID_VPHYSICS)
	self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
	self.Entity:SetSolid(SOLID_VPHYSICS)
	local phys = self.Entity:GetPhysicsObject()

	if phys and phys:IsValid() then phys:Wake() end

	self.Entity:SetNWInt("damage",10)
end

function ENT:OnTakeDamage(dmg)
	self.Entity:SetNWInt("damage",self.Entity:GetNWInt("damage") - dmg:GetDamage())

	if (self.Entity:GetNWInt("damage") <= 0) then
		local effectdata = EffectData()
		effectdata:SetOrigin(self.Entity:GetPos())
		effectdata:SetMagnitude(2)
		effectdata:SetScale(2)
		effectdata:SetRadius(3)
		util.Effect("Sparks", effectdata)
		self.Entity:Remove()
	end
end

function ENT:Use(activator,caller)
	DrugPlayerCoke(caller, pl, ply)
	self.Entity:Remove()
end

function ENT:OnRemove()
	local ply = self.Entity:GetNWEntity("owning_ent")
	ply:SetNWInt("maxDrugs",ply:GetNWInt("maxDrugs") - 1)
end

function DrugPlayerCoke(pl, ply)
	pl:ConCommand("pp_motionblur 1")  
    pl:ConCommand("pp_motionblur_addalpha 0.09")  
    pl:ConCommand("pp_motionblur_delay 0.03")  
    pl:ConCommand("pp_motionblur_drawalpha 0.99") 
    pl:SetWalkSpeed(2000)
	pl:SetRunSpeed(3000)
	pl:SetHealth (50)
	pl:ConCommand("say /y I AM SUPER DUDE HARBLEGARBLEWOOPERDOOP AHHHHHHHHHHHHHHHHH!!!!!! ERRRRR AHHH")


    local IDSteam = string.gsub(pl:SteamID(), ":", "")

    timer.Create(IDSteam, 30, 1, UnDrugPlayer, pl)
end

